package twentytwentyone_3;

/**
 * @Author: Zahi
 * @Description:
 * @Date Created in 2021-03-08 16:37
 * @Modified By:
 */
public class Fib_509 {

    public static void main(String[] args){
        System.out.println(fib(4));
    }

    public static int fib(int n){
        if (n < 2) {
            return n;
        }
        int p = 0, q = 0, r = 1;
        for (int i = 2; i <= n; ++i) {
            p = q;
            q = r;
            r = p + q;
        }
        return r;
    }
}
